﻿using System;
using System.Data;
using System.Data.OleDb;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
//using PowerCreator.LMS.Logic.Common;
using System.Text;
using PowerCreator.LMS.Common.Script;

public partial class sysadmin_UserManager_AddUserInfo_In :PowerCreator.LMS.Web.Base.BasePage
{
    private string ExcelName_New = string.Empty;//实际文件名称
    private string strFileName = string.Empty;//文件格式
    private string error = string.Empty;
    protected void Page_Load(object sender, EventArgs e)
    {

    }



    protected void btnSave_Click(object sender, EventArgs e)
    {
        string GeneralPath = Server.MapPath(PowerCreator.LMS.Common.Utils.WebUtils.WebRoot + "//General.config");
        lab_msg.Visible = true;
        StringBuilder str_msg = new StringBuilder();
        //Excel objExcel = new Excel();
        //if (!UploadFile())
        //{
        //    str_msg.Append("文件上传失败" + error);
        //    lab_msg.Text = "提示信息："+str_msg.ToString();
        //    return;
        //}

        //string msg = objExcel.GetExcelDate(ExcelName_New, GeneralPath);
        string msg = "";
        lab_msg.Text = "提示信息：" +str_msg.ToString()+ msg;
     
    }

    //上传软件
    bool UploadFile()
    {
        if (File1.PostedFile.FileName.Length < 1)
        {
            Script.Alert(Page, "msg", "请选择文件");
            return false;
        }
        string strName = this.File1.PostedFile.FileName.ToString();
        int nlength = strName.Length - strName.LastIndexOf("\\") - 1;
        string ImgName = strName.Substring(strName.LastIndexOf("\\") + 1, nlength);
        //获取软件格式
        strFileName = strName.Substring(strName.LastIndexOf(".")).Replace(".", "");
        if (strFileName.ToLower() != "xls")
        {
            error = "请选择EXCEL文件";
            return false;
        }

        ExcelName_New = Guid.NewGuid() + "." + strFileName.ToLower();
        string sPath = AppDomain.CurrentDomain.BaseDirectory.ToString() + "QuestionDocument\\" + ExcelName_New;
        //string sPath = Server.MapPath(Utils.WebRoot + "\\QuestionDocument\\" + ExcelName_New + ".word"); +"QuestionDocument\\" + ExcelName_New;
        try
        {
            this.File1.PostedFile.SaveAs(sPath);
            return true;
        }
        catch(Exception ex)
        {
            error = ex.Message;
            return false;
        }

    }
    protected void btn_DownLoad_Click(object sender, EventArgs e)
    {
        //Script.RedirectURL(Utils.WebRoot + "/QuestionDocument/AddUser_Demo.xls");
    }
}
